<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="sp" uri="http://www.springframework.org/tags" %>
<html>
<head>
    <title><sp:message code="web.forgetpwd"/></title>
</head>
<body style="padding: 0;margin: 0;">
<span>
    <span class="error-msg">${requestScope.error}</span>
    <span class="success-msg">${requestScope.success}</span>
    <script>
        var errormsg = $('.error-msg').html();
        errormsg= $.trim(errormsg);
        if(errormsg.length>0){
            Common.error(errormsg);
        }else{
            var successmsg=$('.success-msg').html();
            successmsg= $.trim(successmsg);
            if(successmsg.length>0) {
                Common.info(successmsg);
            }
        }
    </script>
</span>
<div style="width: 300px;margin-left: auto;margin-right: auto;">
    <h2><sp:message code="web.forgetpwd"/></h2>

    <div>
        <form id="forgetpwd_form" method="post"
              action="${pageContext.request.contextPath}/admin/user/validateForgetPwd.html">
            <div class="field">
                  <span class="block input-icon input-icon-right">
															<input type="text" class="form-control" placeholder="<sp:message code="web.username" />" autofocus="true"
                                                                   name="userName"
                                                                   datatype="userName"
                                                                   nullmsg="<sp:message code="validate.username.null.error" /> "
                                                                   errormsg="<sp:message code="validate.username.reg.error" /> ">
															<i class="icon-user"></i>
														</span>

                <p class="form_prompt"><sp:message code="web.yourusername.prompt"/></p>
            </div>
            <div class="field">
                <span class="block input-icon input-icon-right">
															<input type="text" class="form-control" placeholder="<sp:message code="web.email" />"
                                                                   name="email"
                                                                   datatype="e"
                                                                   nullmsg="<sp:message code="validate.email.null.error" />"
                                                                   errormsg="<sp:message code="validate.email.reg.error" /> ">
															<i class="icon-envelope"></i>
														</span>
                <p class="form_prompt"><sp:message code="web.youremail.prompt"/></p>
            </div>
            <div class="field">
                <div>
                    <input name="authcode" type="text" datatype="authcode" placeholder="<sp:message code="web.authcode" />"
                           nullmsg="<sp:message code="validate.authcode.null.error" />"
                           errormsg="<sp:message code="validate.authcode.reg.error" /> "/>
                    <img id="forgetpwd_autcode_image" alt="" title="<sp:message code="web.authcode.image.change.title" /> "
                         src="${pageContext.request.contextPath}/codeImg.html" onclick="forgetpwd.authCodeChange(this)"/>
                </div>
                <p class="form_prompt"><sp:message code="web.authcode.prompt"/></p>
            </div>
            <div style="text-align: right">
                <button type="submit" class="btn btn-primary btn-sm">
                    <i class="icon-ok align-top"></i>
                    <sp:message code="web.forgetpwd.send"/>
                </button>
                <button type="button" class="btn btn-purple btn-sm"
                        onclick="window.location.href='${pageContext.request.contextPath}/admin/login.html'">
                    <sp:message code="web.login"/>
                    <i class="icon-arrow-right icon-on-right"></i>
                </button>
            </div>
        </form>
    </div>
</div>

<script>

    $('#forgetpwd_form').Validform({
        btnSubmit: "button[type=submit]",
        showAllError: false,
        postonce: true,
        ajaxPost: false,
        tiptype: function (msg, o, cssctl) {
            if (!o.obj.is("form")) {
                var objtip = o.obj.parent().next(".form_prompt");
                cssctl(objtip, o.type);
                objtip.text(msg);
            }
        },
        beforeSubmit: function (curform) {
            return true;
        }
    });
    $('#forgetpwd_form input').keydown(function (e) {
        if (e.keyCode == 13) {
            $('#forgetpwd_form').submit();
        }
    });
    var forgetpwd = {
        authCodeChange: function (d) {
            $(d).attr("src", "../codeImg.html?d=" + new Date().getTime())
        }
    };
    $('#forgetpwd_form input').keydown(function (e) {
        if (e.keyCode == 13) {
            $('#forgetpwd_form').submit();
        }
    });
</script>
</body>
</html>